package com.chinapost.action;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;

import com.chinapost.po.Tmonth;
import com.chinapost.vo.Json;
import com.opensymphony.xwork2.ModelDriven;

@Action(value = "monthAction")
public class MonthAction extends BaseAction implements ModelDriven<Tmonth> {

	private Tmonth tmonth = new Tmonth();
	@Autowired
	private MonthServiceI monthService;

	public void add(){
		Json j = new Json();
		try {
			monthService.add(tmonth);
			j.setSuccess(true);
			j.setMsg("添加成功！");
		} catch (Exception e) {
			j.setMsg("添加失败！");
		}
		super.writeJson(j);
	}

	/**
	 * 判断当前上传的文件是否比已经上传的数据更新
	 */
	public void do_checkMonth(){
		Json j = new Json();
		j.setSuccess(monthService.checkMonth(tmonth));
		super.writeJson(j);
	}
	
	@Override
	public Tmonth getModel() {
		return tmonth;
	}
	
	
}